const { ethers } = require("hardhat")

async function main() {
    const NFTSHOP = await ethers.getContract("NFTSHOP")
    const BasicNFT = await ethers.getContract("BasicNFT")
    const accounts = ethers.getSigners()

    console.log("mintScript runing ")
    for (let i = 1; i < accounts[6]; i++) {
        await BasicNFT.connect(accounts[i])

        const tx = await (await BasicNFT.mintNft()).wait(1)
        const tokenid = tx.events[0].args.tokenid
        const approve = await BasicNFT.approve(NFTSHOP.address, tokenid)
        approve.wait(1)
        const list = NFTSHOP.listItem(
            BasicNFT.address,
            tokenid,
            ethers.utils.parseEther("0.1")
        )
        list.wait(1)
    }
}
console.log("only run on localhost network")
main()
    .then(() => process.exit(0))
    .catch((e) => {
        console.log(e)
        process.exit(1)
    })
